# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=autorecon
pkgver=297.e7e98f6
pkgrel=1
pkgdesc='A multi-threaded network reconnaissance tool which performs automated enumeration of services.'
groups=('blackarch' 'blackarch-automation' 'blackarch-recon'
        'blackarch-scanner')
arch=('any')
url='https://github.com/Tib3rius/AutoRecon'
license=('GPL3')
depends=('python' 'python-colorama' 'python-toml' 'nmap' 'python-unidecode'
         'feroxbuster' 'oscanner' 'tnscmd' 'redis' 'tnscmd' 'wkhtmltopdf'
         'python-appdirs' 'python-psutil' 'impacket')
optdepends=('curl'
            'enum4linux'
            'gobuster'
            'nbtscan'
            'nikto'
            'onesixtyone'
            'smbclient'
            'smbmap'
            'smtp-user-enum'
            'sslscan'
            'whatweb')
makedepends=('git')
source=("$pkgname::git+https://github.com/Tib3rius/AutoRecon.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm -f README.md LICENSE poetry.lock poetry.toml pyproject.toml \
    requirements.txt

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/$pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"

  find . -type d -iname '__pycache__' -exec rm -rf {} \;
}

